<script setup lang="ts">
import * as echarts from 'echarts';
import { onMounted, ref } from 'vue';
const barChart = ref<HTMLElement>();
const myChart1 = ref<any>();
// 绘制柱形图
function initBarEcharts() {
  // @ts-ignore
  myChart1.value = echarts.init(barChart.value!);
  myChart1.value.setOption({
    xAxis: {
    type: 'category',
    data: ['北京市', '上海市', '天津市', '广州市', '深圳市', '珠海市', '东莞市']
  },
  yAxis: {
    type: 'value'
  },
  series: [
    {
      data: [120, 200, 150, 80, 70, 110, 130],
      type: 'bar',
      showBackground: true,
      backgroundStyle: {
        color: 'rgba(180, 180, 180, 0.2)'
      }
    }
  ]
  });
}
onMounted(() => {
  initBarEcharts();
});
</script>

<template>
  <div ref="barChart" id="barChart" ></div>
</template>

<style scoped>
#barChart{
  background-color: #fff;
  width: 100%;
  height: 90%;
}

</style>